//订单
(function(){
	var db_table_name = "ach";
	var db = require("../db/index");
	//构造函数
	var _con = function (info,events){
		var self = this;
		//订单编号
		self._id = "A_"+Math.random().toString(16).substr(2)+(+new Date).toString(16);
		//额外信息
		self.info = info;
		//该订单的事件集合
		self.events = events||{};
		//是否只读状态
		self.readOnly = false;

		db.insert(db_table_name,self);
		console.log("生成了一个订单：",info.user_id,info.goods_id);
	};
	//技能
	_con.prototype = require("./skill");
	module.exports = _con;
	//静态方法
	_con.get = function(Id){
		var result = db.find_by_id(db_table_name,Id);
		if(result){
			result.__proto__ = _con.prototype;
		}
		return result;
	}
}());
